//app.js
App({
  onLaunch: function () {
    // 展示本地存储能力
    


   
  },
  showMsg: function (msg) {
    wx.showToast({
      title: msg,
      icon: 'none',
      duration: 2000
    })
  },
  wxLogin: function (userInfo) {
    var that = this;
    var res = false;
    wx.login({
      success: function (res) {
        if (res.code) {
          //发起网络请求
          wx.request({
            url: that.appSetting.host + "World/Login?code=" + res.code,
            data: {
              avatarUrl: userInfo.avatarUrl,
              city: userInfo.city,
              country: userInfo.country,
              gender: userInfo.gender,
              language: userInfo.language,
              nickName: userInfo.nickName,
              province: userInfo.province
            },
            method: 'POST',
            header: {
              'content-type': 'application/json' // 默认值
            },
            success: function (res) {

              if (res.data.Status == 0) {
                //存储登录状态
                that.globalData.userInfo = res.data.Result;
                
                res = true;
                //that.getCurrentUserPrice();
              } else {
                that.showMsg(res.data.Message);
              }

            }
          })
        } else {
          that.showMsg("获取用户登录信息失败");
          //wx.showToast("获取用户登录信息失败");
        }
      }
    });
    return res;
  },

  
  globalData: {
    userInfo: null,
    userId: "",
    aaaaa: 123
  },
  appSetting: {
    //host: 'http://192.168.39.75:8018/api/world/'
    //host: 'http://192.168.0.102:8085/api/world/'
    host: 'https://wxapi.zixunmanyou.com/api/world/'
  }
})